﻿using SMTPAPI.InterfaceImplementation;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Net.Mail;
using Moq;
using System.IO;

namespace SMTPAPIUnitTest
{
    
    
    /// <summary>
    ///This is a test class for AttachAttachmentTest and is intended
    ///to contain all AttachAttachmentTest Unit Tests
    ///</summary>
    [TestClass()]
    public class AttachAttachmentTest
    {

        /// <summary>
        ///A test for AttachedAttachment - since we have to use actuall attachement here this is not type of unit test.
        ///This is a type of integration test.
        ///</summary>
        [TestMethod()]
        public void AttachedAttachmentTest_ForSuccessSenario()
        {
            AttachAttachment target = new AttachAttachment();
            IList<string> attachmentList = new List<string>();

            attachmentList.Add(@"Koala.jpg");
            attachmentList.Add(@"Penguins.jpg");
            attachmentList.Add(@"Tulips.jpg");

            MailMessage mailMessage = new MailMessage(); ; 
            target.AttachedAttachment(attachmentList, mailMessage);

            int expectedAttachmentCount = 3;
            Assert.AreEqual(expectedAttachmentCount, mailMessage.Attachments.Count);
        }

        /// <summary>
        ///A test for AttachedAttachment - Here we test AttachedAttachment method for invalid attachment path.
        ///</summary>
        [TestMethod()]
        [ExpectedException(typeof(DirectoryNotFoundException))]
        public void AttachedAttachmentTest_ForInvalidAttachmentPath()
        {
            AttachAttachment target = new AttachAttachment();
            IList<string> attachmentList = new List<string>();

            attachmentList.Add(@"D:/Resources/Koala.jpg");

            MailMessage mailMessage = new MailMessage(); ;
            target.AttachedAttachment(attachmentList, mailMessage);
        }

        /// <summary>
        ///A test for AttachedAttachment - Here we test AttachedAttachment method for  attachment path null value.
        ///</summary>
        [TestMethod()]
        [ExpectedException(typeof(ArgumentNullException))]
        public void AttachedAttachmentTest_ForAttachmentPathForNull()
        {
            AttachAttachment target = new AttachAttachment();
            IList<string> attachmentList = new List<string>();

            attachmentList.Add(null);

            MailMessage mailMessage = new MailMessage(); ;
            target.AttachedAttachment(attachmentList, mailMessage);
        }

    }
}
